function watch(obj, name = 'obj') {
    const cache = new WeakMap(), accessed = new WeakMap();

    const safeString = v => {
        try {
            return JSON.stringify(v)
        } catch {
            return '[Circular or non-serializable]'
        }
    };

    const DEBUG_MODE = true; // 设置为 true 以启用调试日志
    const proxy = (target, path) => {
        if (typeof target !== 'object' || target === null || cache.has(target) ||
            target instanceof Date || target instanceof RegExp) {
            return target;
        }

        const handler = {
            get(t, p, r) {
                if (typeof p === 'symbol') return Reflect.get(t, p, r);
                const desc = Object.getOwnPropertyDescriptor(t, p);
                if (desc && 'value' in desc) {
                    const value = desc.value;
                    const props = accessed.get(t) || accessed.set(t, new Set()).get(t);
                    if (!props.has(p)) {
                        props.add(p);
                        if (DEBUG_MODE) {
                            console.table([`get => <${path}> 读取: ${p} 类型: ${typeof value} 值: ${typeof value === 'function' ? 'f()' : safeString(value)}`]);
                        }
                    }
                    return typeof value === 'object' && value !== null ? proxy(value, `${path}.${p}`) : value;
                } else {
                    return Reflect.get(t, p, r);
                }
            },

            set(t, p, v, r) {
                if (typeof p === 'symbol') return Reflect.set(t, p, v, r);
                const props = accessed.get(t) || accessed.set(t, new Set()).get(t);
                if (!props.has(p)) {
                    props.add(p);
                    if (DEBUG_MODE) {
                        console.table([`set => <${path}> 设置: ${p} 类型: ${typeof v} 新值: ${safeString(v)}`]);
                    }
                }
                return Reflect.set(t, p, v, r);
            }
        };

        const proxyObj = new Proxy(target, handler);
        cache.set(target, proxyObj);
        return proxyObj;
    };

    return proxy(obj, name);
}